home *** CD-ROM | disk | FTP | other *** search
Wrap
.TH REGEXP .SH NAME Regexp Regular expression pattern matching .SH SYNOPSIS #include <cool/Regexp.h> .SH DESCRIPTION A regular expression allows a programmer to specify complex patterns that can be searched for and matched against the character string of a string object. In its simplest form, a regular expression is a sequence of characters used to search for exact character matches. However, many times the exact sequence to be found is not known, or only a match at the beginning or end of a string is desired. The cool regular expression class implements regular expression pattern matching as is found and implemented in many UNIX commands and utilities. .PP The regular expression class provides a convenient mechanism for specifying and manipulating regular expressions. The regular expression object allows specification of such patterns by using the following regular expression metacharacters: .TP 10 ^ Matches at beginning of a line .TP 10 $ Matches at end of a line .TP 10 \|. Matches any single character .TP 10 [ ] Matches any character(s) inside the brackets .TP 10 [^ ] Matches any character(s) \f2not\f1 inside the brackets .TP 10 \- Matches any character in range on either side of a dash .TP 10 * Matches preceding pattern zero or more times .TP 10 + Matches preceding pattern one or more times .TP 10 ? Matches preceding pattern zero or once only .TP 10 () Saves a matched expression and uses it in a later match .PP Note that more than one of these metacharacters can be used in a single regular expression in order to create complex search patterns. For example, the pattern [^ab1-9] says to match any character sequence that does not begin with the characters "ab" followed by numbers in the series one through nine. .SH Base Classes .SH Friend Classes None .SH Constructors .TP inline Regexp (); Creates an empty regular expression object with no private data initialized. .TP \f3inline Regexp (char* \f2str\f3);\f1 Creates a regular expression object and initializes all the data by compiling the regular expression provided \f2str\f1. If an invalid regular expression is detected, an \f3\f3Error\f1\f1 exception is raised. .TP \f3Regexp (const Regexp& \f2reg\f3);\f1 Creates a regular expression object and duplicates the values and regular expression of another regular expression object reg . .SH Member Functions .TP \f3void compile (char* \f2str\f3);\f1 Creates a compiled version of the argument \f2str\f1 and places it in the private data. If an invalid expression is detected, an \f3\f3Error\f1\f1 exception is raised. .TP \f3Boolean deep_equal (const Regexp& \f2reg\f3) const;\f1 Determines if two regular expressions are the same, including the zero-relative start and end indexes of the last successful pattern match. This function returns \f3TRUE\f1 if the expressions are the same; otherwise, this function returns \f3FALSE\f1. .TP inline long end () const; Returns an index into the last character string successfully searched for by this object. The index corresponds to the character after the last item found. If none are found, its value is NULL . .TP \f3Boolean find (char* \f2str\f3);\f1 Searches for the already specified regular expression in str . If the expression is found, this function returns \f3TRUE\f1 and sets start and end indexes appropriately. If an invalid expression is detected, an \f3\f3Error\f1\f1 exception is raised. .TP inline Boolean is_valid () const; Returns \f3TRUE\f1 if a valid regular expression is compiled and ready for use; otherwise, this function returns \f3FALSE\f1. .TP \f3Boolean operator== (const Regexp& \f2reg\f3) const;\f1 Determines if two regular expression objects are the same. This function returns \f3TRUE\f1 if the expression objects are the same; otherwise, this function returns \f3FALSE\f1. .TP \f3inline Boolean operator!= (const Regexp& \f2reg\f3) const;\f1 Determines if two regular expression objects are not the same. This function returns \f3TRUE\f1 if the expression objects are different; otherwise, this function returns \f3FALSE\f1. .TP inline void set_invalid (); Invalidates the current regular expression of the regular expression object. .TP inline long start () const; Returns an index into the last character string successfully searched for by this object. The index corresponds to the beginning of the last item found. If none are found, its value is \f3NULL\f1. .SH COPYRIGHT Copyright (C) 1991 Texas Instruments Incorporated. Permission is granted to any individual or institution to use, copy, modify, and distribute this software, provided that this complete copyright and permission notice is maintained, intact, in all copies and supporting documentation. Texas Instruments Incorporated provides this software "as is" without express or implied warranty.